home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / win_nt95 / cm95-10.zip / CUPCAKE.TS < prev    next >
Text File  |  1996-10-29  |  6KB  |  211 lines

  1. ;****************************************************************************
  2. ; ClockMan95 Automation Assistant support file - TAPCIS script
  3. ; (c) 1995 Graphical Dynamics, Inc. The "Common helper functions" are placed
  4. ; in the public domain; otherwise permission is granted to use/modify this
  5. ; script file as long as it's not for resale.
  6. ;
  7. ; Written by: Jennifer Palonus
  8. ;
  9. ; Date    Who   Major changes
  10. ;-------  ---   -------------------------------------------------------------
  11. ;22nov95  jlp   Created.
  12. ;22nov95
  13. ;****************************************************************************
  14.  
  15. [*About this script*]
  16. Gets the latest Cupcake's CB Society Column, a twice-monthly newsletter for
  17. Compuserve CB aficionados.
  18.  
  19. [*Script Setup*]
  20. Title=Cupcake's CB Society Column
  21.  
  22. ;****************************************************************************
  23. ; Main processing section.
  24. ;****************************************************************************
  25.  
  26. [*MenuItems*]
  27. item=1
  28.  
  29.  
  30. [Begin]
  31.     set @Timeout# 120
  32.     let ServiceName$    = "CIS:CUPCAKE"
  33.     let ServiceHasHdr    = @FALSE
  34.     let SubjectLine$    = "Cupcake's CB Society Column"
  35.     let Prompt$            = "^J!"
  36.     gosub "GoService"
  37.     if (OK = @FALSE) fail
  38.  
  39.     ForEach in MenuItems[] gosub "HandleMenu"
  40.     if (HMTFound = @FALSE) end
  41.  
  42.     gosub "CaptureMsg"
  43.     end
  44.  
  45.  
  46. ;****************************************************************************
  47. ; Common helper functions. (These are placed in the "public domain" by GDI.)
  48. ;****************************************************************************
  49. ; [GoService]
  50. ;
  51. ; Carries out a GO command & passes over the introductory text (if any).
  52. ; When this returns, you're ready to capture or parse the service's top menu.
  53. ;
  54. ; ServiceName$        The CIS service you want to GO to.
  55. ; ServiceHasHdr        Does this service have an intro paragraph ending with a
  56. ;                    "MORE !" prompt?
  57. ;****************************************************************************
  58. [GoService]
  59.     let OK = @TRUE
  60.     send "GO " ServiceName$
  61.  
  62.     if (ServiceHasHdr = @FALSE) return
  63.     let Prompt$ = "^JMORE !"         
  64.     gosub "WaitForPrompt"
  65.     send ""
  66.     return
  67.  
  68.     
  69. ;****************************************************************************
  70. ; [HandleMenu]
  71. ;
  72. ; Traverses the tree of menus until you're ready to capture a particular
  73. ; article. To call this function, declare an array section (ex.: [*Menus*])
  74. ; with menu item text and/or item numbers to look for, in either of these forms:
  75. ;     text=<text in menu item>
  76. ;     item=<menu item's number>
  77. ;     
  78. ; Then, call this function in a ForEach stmt: ForEach in Menus[] gosub "HandleMenu"
  79. ;
  80. ; SubjectLine$        The generated mail message's subject line.
  81. ; Prompt$            The prompt that ends the article. Usu. "^J!".
  82. ;
  83. ; Upon return, OK is @TRUE or @FALSE depending on whether any matching items
  84. ; were found. If @TRUE then you're ready to capture the selected article or
  85. ; parse the submenu.
  86. ;****************************************************************************
  87. [HandleMenu]
  88.     let HMTFound = @FALSE
  89.     ;Dispatch to HMText or HMItem, depending on how to choose menu item (by
  90.     ;"Text" or menu "Item" #)...
  91.     goto "HM" @arrItem$
  92.     ;else bad menu cmd...
  93.          Echo "Unrecognized menu item search type '" @arrItem$ "' in [HandleMenu]"
  94.         fail
  95.  
  96. [HMText]
  97.     let HMSearchText$ = @arrValue$
  98.  
  99. ;1 or more menu sections. If >1, they're separated by "MORE !" prompts...
  100. [HMTLoop]
  101.     waitlist
  102.         1 = "^JMORE !"
  103.         2 = "^J!"
  104.     endlist
  105.     DoWaitMenu TheMenuLines[]
  106.     if (@waitMatch# = 0) goto "HMTNoMatchTimeout"
  107.  
  108.     ForEach in TheMenuLines[] gosub "HMTSelectItem"
  109.     if (HMTFound = @TRUE) return
  110.  
  111. [HMTNoMatch]
  112.     if (@waitMatch# = 1) goto "HMTNoMatchMore"
  113.     if (@waitMatch# = 2) goto "HMTNoMatchEOM"
  114.  
  115. [HMTNoMatchTimeout]
  116.     Echo "Timed out waiting for full menu"
  117.     fail
  118.  
  119. [HMTNoMatchMore]
  120.     send ""
  121.     goto "HMTLoop"
  122.  
  123. [HMTNoMatchEOM]
  124.     return
  125.  
  126.  
  127. [HMTSelectItem]
  128.     if (HMTFound = @TRUE) return
  129.  
  130.     if (@strstr (@arrValue$, HMSearchText$) = @FALSE) return
  131.     let HMTFound = @TRUE
  132.     Echo "We found '" HMSearchText$ "': #" @arrItem$ " = '" @arrValue$ "'!"
  133.     
  134.     send @arrItem$
  135.     return
  136.  
  137.  
  138. [HMItem]
  139.     let HMTFound = @TRUE
  140.     let Prompt$ = ""
  141.     gosub "WaitForPrompt"
  142.  
  143.     Echo "Selecting item #" @arrValue$
  144.     send @arrValue$
  145.     return
  146.  
  147.     
  148. ;****************************************************************************
  149. ; [CaptureMsg]
  150. ;
  151. ; Assuming CIS is about to send us the text that we want to place into a mail
  152. ; message, this routine captures the text 'till we get a <CR> & ! prompt.
  153. ;
  154. ; SubjectLine$        The custom subject line if different than the default.
  155. ; Prompt$            The prompt that ends the article. Usu. "^J!".
  156. ;****************************************************************************
  157. [CaptureMsg]
  158.     if (@capName$ = "") let @capName$ = @pathMsg$ @svcName$ '.MSG'
  159.     let @hdrSub$ = SubjectLine$
  160.     Echo "Capturing article to " @capName$
  161.     CapHeader
  162.  
  163.     let OK = @TRUE
  164.  
  165.     let Prompt$ = "^J!"
  166.     gosub "WaitForPrompt"
  167.     CapClose
  168.  
  169.     let SubjectLine$ = ""
  170.     return
  171.  
  172.  
  173. ;****************************************************************************
  174. ; [WaitForPrompt]
  175. ;
  176. ; Wait till the end of a menu or opening text. This routine handles menus
  177. ; split up into multiple chunks, each of which end in "MORE !" prompts.
  178. ; If you DO want to wait for "MORE !", then set Prompt$ to it.
  179. ;
  180. ; Prompt$            The prompt you're waiting for. Usu. "^J!".
  181. ;****************************************************************************
  182. [WaitForPrompt]
  183.     let OK = @TRUE
  184.     if (Prompt$ = "") let Prompt$ = "^J!"
  185.  
  186. [WFPLoop]
  187.     waitlist
  188.         1 = Prompt$
  189.         2 = "^JMORE !"
  190.         3 = "^J!"
  191.     endlist
  192.     DoWaitMenu TheMenuLines[]
  193.     if (@waitMatch# = 1) return
  194.     if (@waitMatch# = 2) goto "WFPMore"
  195.     if (@waitMatch# = 3) return
  196.  
  197.     ; else...
  198.     let OK = @FALSE
  199.     Echo "...timed out waiting for a prompt"
  200.     return
  201.  
  202. [WFPMore]
  203.     Send ""
  204.     goto "WFPLoop"
  205.  
  206.  
  207. ;****************************************************************************
  208. [HandleErrors]
  209.     fail
  210.  
  211.